<script setup>
    import {ref} from 'vue'
    import {useRouter, useRoute} from 'vue-router'

    let route = useRoute()
    let router = useRouter()

    let username = window.localStorage.getItem('username')

    let logout = () => {
        //清楚 localStorge 中的 username
        window.localStorage.removeItem('username')
        // 动态路由到登录页
        router.push('/login')
    }
</script>

<template>
  <div>
    <h1> Home 页面</h1>
    <h3>欢迎{{username}}登录</h3>
    <button @click="logout()">退出登录</button>
  </div>
</template>

<style scoped>
</style>
